<div class="dropdown order_by_selector2" li_selected="<%= params[:sort_by] || "popularity" %>" id="order_by_selector_net">

  <button class="btn btn-default dropdown-toggle dropdownMenuOrdBy" type="button" data-toggle="dropdown">
    <i class="fa fa-desktop"> </i>

    <%=t('order_by.popularity')%>
    <i class="fa fa-angle-down"></i>
  </button>
  <ul class="dropdown-menu dropdown-menu-left" role="menu" aria-labelledby="dLabel">
    <li>
        <a href="<%=home_path(:tab=>"net", :sort_by=>"popularity")%>" sort-by-key='popularity'>
          <i class="fa fa-dashboard"></i>
          <%=t('order_by.popularity')%>
        </a>
    </li>
    <li>
      <a href="<%=home_path(:tab=>"net", :sort_by=>"updated_at")%>" sort-by-key='updated_at'>
        <i class="fa fa-pencil"></i>
        <%=t('order_by.updated_at')%>
      </a>
    </li>
    <li>
      <a href="<%=home_path(:tab=>"net", :sort_by=>"created_at")%>" sort-by-key='created_at'>
        <i class="fa fa-bolt"></i>
        <%=t('order_by.created_at')%>
      </a>
    </li>
    <li>
        <a href="<%=home_path(:tab=>"net", :sort_by=>"visits")%>" sort-by-key='visits'>
          <i class="fa fa-eye"></i>
          <%=t('order_by.visits')%>
        </a>
    </li>
    <li>
        <a href="<%=home_path(:tab=>"net", :sort_by=>"favorites")%>" sort-by-key='favorites'>
          <i class="fa fa-star"></i>
          <%=t('order_by.favorites')%>
        </a>
    </li>
  </ul>

</div>

<script>
  document.addEventListener("DOMContentLoaded", function(){
    var param = "<%=params[:sort_by]%>";

    if(param && param!=""){
      if(param=="ranking"){
        param = "popularity";
      }
      var value = $(".order_by_selector .dropdown-menu [sort-by-key="+param+"]").html();
      $(".dropdownMenuOrdBy").html(value + '<i class="fa fa-angle-down"></i>');
    }
  });
</script>
